Skip to content

Conversation

MariusStorhaug
Copy link
Member

@MariusStorhaug MariusStorhaug commented Jul 7, 2025

Description

This pull request introduces several new features and improvements to the PowerShell module for managing GitHub organizations and apps. Key changes include new functions for creating and managing organizations, enhancements to app installation workflows, and updates to testing coverage for these functionalities.

New and updated functions

  • Added a New-GitHubOrganization function to create GitHub organizations within a specified enterprise. This includes support for specifying owners, billing emails, and enterprise contexts.
  • Updated the Remove-GitHubOrganization function to support removing multiple organizations via an array input parameter, improving flexibility.

Improvements to App Installation

  • Modified the Install-GitHubAppOnEnterpriseOrganization function to validate repository selection values case-insensitively and return strongly-typed GitHubAppInstallation objects.

Updates to Organization Properties

  • Corrected property mappings in the GitHubOrganization class to ensure accurate handling of RequireWebCommitSignoff.

Testing Enhancements

  • Added new tests for organization creation, updates, app installation, and removal, improving validation for enterprise workflows.

Debugging Improvements

  • Updated Invoke-GitHubAPI to include detailed context information in error messages, aiding debugging efforts.

Type of change

  • 📖 [Docs]
  • 🪲 [Fix]
  • 🩹 [Patch]
  • ⚠️ [Security fix]
  • 🚀 [Feature]
  • 🌟 [Breaking change]

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas

…ository Rule Suites (Insights) (#461)

## Description

This pull request introduces several changes across multiple files to
enhance the functionality and structure of GitHub-related classes in the
codebase. The most notable updates include replacing `HostName` with
`GitHubContext` for improved context management, restructuring
properties in `GitHubOwner` subclasses, and updating XML format
definitions to reflect the new structure.

- Fixes #454

### Context Management Updates:
* Replaced the `HostName` parameter with `GitHubContext` in constructors
across multiple classes (`GitHubAppInstallation`, `GitHubArtifact`,
`GitHubEnvironment`, `GitHubOrganization`). This change centralizes
context-related properties, such as `HostName`, for better scalability
and readability.

### GitHubOwner Class Restructuring:
* Removed redundant properties (e.g., `Company`, `Blog`, `Plan`) from
the `GitHubOwner` class and its subclasses (`GitHubEnterprise`,
`GitHubOrganization`, `GitHubUser`). Added new properties such as
`Description` and `Website` to better align with GraphQL schema
mappings.

### GraphQL Mapping Enhancements:
* Introduced static `$PropertyToGraphQLMap` hashtables in
`GitHubEnterprise` and `GitHubOrganization` classes to define mappings
between class properties and GraphQL fields, improving maintainability
and integration with GraphQL APIs.

### XML Format Updates:
* Updated the `GitHubOwner.Format.ps1xml` file to include new properties
(`DisplayName`, `CreatedAt`) in table views for improved visualization
of `GitHubOwner` objects. Removed deprecated columns such as `Company`
and `Plan`.

## Type of change

<!-- Use the check-boxes [x] on the options that are relevant. -->

- [ ] 📖 [Docs]
- [ ] 🪲 [Fix]
- [x] 🩹 [Patch]
- [ ] ⚠️ [Security fix]
- [ ] 🚀 [Feature]
- [ ] 🌟 [Breaking change]

## Checklist

<!-- Use the check-boxes [x] on the options that are relevant. -->

- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- Created TEMPLATE.ps1 for Pester testing framework setup.
- Added Teams.Tests.ps1 to test GitHub Teams API functionalities.
- Introduced Users.Tests.ps1 for user-related API tests.
- Developed Variables.Tests.ps1 to manage GitHub repository variables.
- Each test script includes setup and teardown logic for authentication and resource cleanup.
- Implemented various test cases for creating, updating, retrieving, and deleting GitHub resources.
@MariusStorhaug MariusStorhaug self-assigned this Jul 7, 2025
@Copilot Copilot AI review requested due to automatic review settings July 7, 2025 08:01
@MariusStorhaug MariusStorhaug requested a review from a team as a code owner July 7, 2025 08:01
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds the New-GitHubOrganization function and harmonizes several parameter names and context handling across the module.

  • Introduces New-GitHubOrganization for creating organizations via GraphQL mutations.
  • Renames BlogWebsite and BioDescription in user/org cmdlets and tests.
  • Replaces HostName parameters with GitHubContext objects and updates constructors accordingly.

Reviewed Changes

Copilot reviewed 48 out of 59 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/Organizations.Tests.ps1 Adds setup/teardown for enterprise orgs; new New-GitHubOrganization test
test2/Users.Tests.ps1 Updates Update-GitHubUser tests to use -Website/-Description and asserts new properties
test2/Enterprise.Tests.ps1 Adjusts enterprise tests to skip non-enterprise and validate Website
src/functions/public/Organization/New-GitHubOrganization.ps1 Implements creation via GraphQL for new orgs
src/functions/public/Users/Update-GitHubUser.ps1 Renames -Bio to -Description and -Blog to -Website
src/functions/public/Organization/Update-GitHubOrganization.ps1 Renames parameters and updates request body mappings
src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 Removed org alias on $Owner parameter
src/classes/public/Owner/GitHubOwner/GitHubOrganization.ps1 Updates constructor to use GitHubContext; adds new properties and fallback logic
Comments suppressed due to low confidence (2)

src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1:41

  • Removing the org alias for the $Owner parameter breaks backward compatibility. Consider keeping the alias or updating documentation/examples to use the new parameter name explicitly.
        [Parameter()]

.github/PSModule.yml:18

  • [nitpick] Setting Skip: true for CodeCoverage while also specifying a PercentTarget: 50 is contradictory. Either remove the skip or adjust the coverage target to ensure coverage metrics are enforced.
    Skip: true

…Install-GitHubAppOnEnterpriseOrganization function; remove obsolete tests from Organizations.Tests
… wildcard matching and add -WhatIf parameter for safety
…y parameters for organization name and owners; improve debug logging in process block
…g organization details before removal; improve organization retrieval in tests
… parameter for organization retrieval in enterprise context; ensure accurate logging of organizations
…e unnecessary enterprise parameter and cleanup calls
… parameter for organization retrieval in enterprise context
…g unnecessary logging and directly removing organizations for enterprise context
…d add tests for app installation and organization updates
- Created TEMPLATE.ps1 for standardized test structure.
- Implemented Teams.Tests.ps1 to validate GitHub Teams functionality, including team creation, retrieval, updating, and deletion.
- Developed Users.Tests.ps1 to test user-related API calls, including user retrieval and updates.
- Added Variables.Tests.ps1 to cover GitHub variable management, including setting, updating, and removing variables for users and organizations.
- Each test file includes setup and teardown logic to ensure a clean testing environment.
- Utilized Pester's logging capabilities to enhance output visibility during test execution.
@MariusStorhaug MariusStorhaug merged commit c15c9f4 into main Jul 7, 2025
11 checks passed
@MariusStorhaug MariusStorhaug deleted the organization branch July 7, 2025 20:16
@github-project-automation github-project-automation bot moved this from Todo to Done in GitHub PowerShell Module Jul 7, 2025
Copy link
Contributor

github-actions bot commented Jul 7, 2025

Module GitHub - 0.33.8 published to the PowerShell Gallery.

Copy link
Contributor

github-actions bot commented Jul 7, 2025

GitHub release for GitHub v0.33.8 has been created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

🚀[Feature]: Add function New-GitHubOrganization

1 participant